Repository: Products.CMFPlone
Branch: refs/heads/master
Date: 2014-11-14T15:40:08+01:00
Author: JC Brand (jcbrand) <jc@opkode.com>
Commit: https://github.com/plone/Products.CMFPlone/commit/e90963057c2aae9a1039c184f15dc8e68337abdd

Changes required to Plone for pat-cookietrigger.

Updates #282

* Remove login.js, this code is now in pat-cookietrigger
* Add pat-cookietrigger to registry.xml

Files changed:
M Products/CMFPlone/profiles/dependencies/registry.xml
M Products/CMFPlone/skins/plone_login/failsafe_login_form.cpt
M Products/CMFPlone/skins/plone_login/logged_out.cpt
M Products/CMFPlone/skins/plone_login/login_failed.cpt
M Products/CMFPlone/skins/plone_login/login_form.cpt
M Products/CMFPlone/skins/plone_login/registered.pt
M Products/CMFPlone/static/plone.js
D Products/CMFPlone/skins/plone_ecmascript/login.js

diff --git a/Products/CMFPlone/profiles/dependencies/registry.xml b/Products/CMFPlone/profiles/dependencies/registry.xml
index 29d27ec..bcb8ddc 100644
--- a/Products/CMFPlone/profiles/dependencies/registry.xml
+++ b/Products/CMFPlone/profiles/dependencies/registry.xml
@@ -655,6 +655,11 @@
       <value key="js">++resource++mockup/backdrop/pattern.js</value>
   </records>
 
+  <records prefix="plone.resources/mockup-patterns-cookietrigger"
+            interface='Products.CMFPlone.interfaces.IResourceRegistry'>
+      <value key="js">++resource++mockup/cookietrigger/pattern.js</value>
+  </records>
+
   <records prefix="plone.resources/mockup-patterns-sortable"
             interface='Products.CMFPlone.interfaces.IResourceRegistry'>
       <value key="js">++resource++mockup/sortable/pattern.js</value>
diff --git a/Products/CMFPlone/skins/plone_ecmascript/login.js b/Products/CMFPlone/skins/plone_ecmascript/login.js
deleted file mode 100644
index a66dc13..0000000
--- a/Products/CMFPlone/skins/plone_ecmascript/login.js
+++ /dev/null
@@ -1,74 +0,0 @@
-// Functions used by login pages
-
-function cookiesEnabled() {
-  // Test whether cookies are enabled by attempting to set a cookie and then change its value
-  // set test cookie
-  var c = "areYourCookiesEnabled=0";
-  document.cookie = c;
-  var dc = document.cookie;
-  // cookie not set?  fail
-  if (dc.indexOf(c) == -1) return 0;
-  // change test cookie
-  c = "areYourCookiesEnabled=1";
-  document.cookie = c;
-  dc = document.cookie;
-  // cookie not changed?  fail
-  if (dc.indexOf(c) == -1) return 0;
-  // delete cookie
-  document.cookie = "areYourCookiesEnabled=; expires=Thu, 01-Jan-70 00:00:01 GMT";
-  return 1;
-}
-
-function setLoginVars(user_name_id, alt_user_name_id, password_id, empty_password_id, js_enabled_id, cookies_enabled_id) {
-  // Indicate that javascript is enabled, set cookie status, copy username and password length info to 
-  // alternative variables since these vars are removed from the request by zope's authentication mechanism.
-  if (js_enabled_id) {
-    el = document.getElementById(js_enabled_id);
-    if (el) { el.value = 1; }
-  }
-  if (cookies_enabled_id) {
-    el = document.getElementById(cookies_enabled_id);
-    // Do a fresh cookies enabled test every time we press the login button
-    //   so that we are up to date in case the user enables cookies after seeing
-    //   the cookies message.
-    if (el) { el.value = cookiesEnabled(); } 
-  }
-  if (user_name_id && alt_user_name_id) {
-    user_name = document.getElementById(user_name_id)
-    alt_user_name = document.getElementById(alt_user_name_id)
-    if (user_name && alt_user_name) {
-       alt_user_name.value = user_name.value;
-    } 
-  }
-  if (password_id && empty_password_id) {
-    password = document.getElementById(password_id)
-    empty_password = document.getElementById(empty_password_id)
-    if (password && empty_password) {
-       if (password.value.length==0) {
-          empty_password.value = '1';
-       } else {
-          empty_password.value = '0';
-       }
-    }
-  }
-  return 1;
-}
-
-function showCookieMessage(msg_id) {
-  // Show the element with the given id if cookies are not enabled
-  msg = document.getElementById(msg_id)
-  if (msg) {
-     if (cookiesEnabled()) {
-        msg.style.display = 'none';
-     } else {
-        msg.style.display = 'block';
-     }
-  }
-}
-
-function showEnableCookiesMessage() {
-  // Show the element with the id 'enable_cookies_message' if cookies are not enabled
-  showCookieMessage('enable_cookies_message')
-}
-// Call showEnableCookiesMessage after the page loads
-jQuery(showEnableCookiesMessage);
diff --git a/Products/CMFPlone/skins/plone_login/failsafe_login_form.cpt b/Products/CMFPlone/skins/plone_login/failsafe_login_form.cpt
index 224707e..7a58954 100644
--- a/Products/CMFPlone/skins/plone_login/failsafe_login_form.cpt
+++ b/Products/CMFPlone/skins/plone_login/failsafe_login_form.cpt
@@ -43,9 +43,7 @@ If you do not have an account here, head over to the
 </p>
 
 
-<div class="portalMessage error"
-    id="enable_cookies_message"
-    style="display:none">
+<div class="portalMessage error pat-cookietrigger" style="display:none">
     <strong i18n:translate="">
         Error
     </strong>
diff --git a/Products/CMFPlone/skins/plone_login/logged_out.cpt b/Products/CMFPlone/skins/plone_login/logged_out.cpt
index b05ea0f..e00fbcf 100644
--- a/Products/CMFPlone/skins/plone_login/logged_out.cpt
+++ b/Products/CMFPlone/skins/plone_login/logged_out.cpt
@@ -6,11 +6,6 @@
       i18n:domain="plone">
 
 <head>
-    <metal:js fill-slot="javascript_head_slot">
-        <script type="text/javascript" src=""
-                tal:attributes="src string:${context/portal_url}/login.js">
-        </script>
-    </metal:js>
     <metal:block fill-slot="top_slot"
                  tal:define="dummy python:request.set('disable_border',1);
                              disable_column_one python:request.set('disable_plone.leftcolumn',1);
diff --git a/Products/CMFPlone/skins/plone_login/login_failed.cpt b/Products/CMFPlone/skins/plone_login/login_failed.cpt
index 48a9e0a..6a35335 100644
--- a/Products/CMFPlone/skins/plone_login/login_failed.cpt
+++ b/Products/CMFPlone/skins/plone_login/login_failed.cpt
@@ -7,11 +7,6 @@
       i18n:domain="plone">
 
 <head>
-    <metal:js fill-slot="javascript_head_slot">
-        <script type="text/javascript" src=""
-                tal:attributes="src string:${context/portal_url}/login.js">
-        </script>
-    </metal:js>
     <metal:block fill-slot="top_slot"
                  tal:define="dummy python:request.set('disable_border',1);
                              disable_column_one python:request.set('disable_plone.leftcolumn',1);
diff --git a/Products/CMFPlone/skins/plone_login/login_form.cpt b/Products/CMFPlone/skins/plone_login/login_form.cpt
index 9da9e5a..bbf7c07 100644
--- a/Products/CMFPlone/skins/plone_login/login_form.cpt
+++ b/Products/CMFPlone/skins/plone_login/login_form.cpt
@@ -6,11 +6,6 @@
       i18n:domain="plone">
 
 <head>
-    <metal:js fill-slot="javascript_head_slot">
-        <script type="text/javascript" src=""
-                tal:attributes="src string:${context/portal_url}/login.js">
-        </script>
-    </metal:js>
     <metal:block fill-slot="top_slot"
                  tal:define="dummy python:request.set('disable_border',1);
                              disable_column_one python:request.set('disable_plone.leftcolumn',1);
@@ -55,9 +50,7 @@
                         target python:test(target in ('_parent', '_top', '_blank', '_self'), target, None);
                         ztu modules/ZTUtils;">
 
-            <div class="portalMessage error"
-                id="enable_cookies_message"
-                style="display:none">
+            <div class="portalMessage error pat-cookietrigger" style="display:none">
                 <strong i18n:translate="">
                     Error
                 </strong>
diff --git a/Products/CMFPlone/skins/plone_login/registered.pt b/Products/CMFPlone/skins/plone_login/registered.pt
index 59ac0df..a8fe7e1 100644
--- a/Products/CMFPlone/skins/plone_login/registered.pt
+++ b/Products/CMFPlone/skins/plone_login/registered.pt
@@ -45,9 +45,7 @@
                     Click the button to log in immediately.
                 </p>
 
-                <div class="portalMessage error"
-                    id="enable_cookies_message"
-                    style="display:none">
+                <div class="portalMessage error pat-cookietrigger" style="display:none">
                     <strong i18n:translate="">
                         Error
                     </strong>
diff --git a/Products/CMFPlone/static/plone.js b/Products/CMFPlone/static/plone.js
index b79b820..ab9b442 100644
--- a/Products/CMFPlone/static/plone.js
+++ b/Products/CMFPlone/static/plone.js
@@ -34,6 +34,7 @@ require([
   'plone-patterns-toolbar',
   'mockup-patterns-accessibility',
   'mockup-patterns-autotoc',
+  'mockup-patterns-cookietrigger',
   'mockup-patterns-formunloadalert',
   'mockup-patterns-preventdoublesubmit',
   'mockup-patterns-inlinevalidation',


Repository: Products.CMFPlone
Branch: refs/heads/master
Date: 2014-11-14T08:48:41-06:00
Author: Nathan Van Gheem (vangheem) <vangheem@gmail.com>
Commit: https://github.com/plone/Products.CMFPlone/commit/d9b43f1728898543eaded6674a3902fca5e47f48

Merge pull request #301 from plone/cookiewarning

Changes required to Plone for pat-cookietrigger.

Files changed:
M Products/CMFPlone/profiles/dependencies/registry.xml
M Products/CMFPlone/skins/plone_login/failsafe_login_form.cpt
M Products/CMFPlone/skins/plone_login/logged_out.cpt
M Products/CMFPlone/skins/plone_login/login_failed.cpt
M Products/CMFPlone/skins/plone_login/login_form.cpt
M Products/CMFPlone/skins/plone_login/registered.pt
M Products/CMFPlone/static/plone.js
D Products/CMFPlone/skins/plone_ecmascript/login.js

diff --git a/Products/CMFPlone/profiles/dependencies/registry.xml b/Products/CMFPlone/profiles/dependencies/registry.xml
index 29d27ec..bcb8ddc 100644
--- a/Products/CMFPlone/profiles/dependencies/registry.xml
+++ b/Products/CMFPlone/profiles/dependencies/registry.xml
@@ -655,6 +655,11 @@
       <value key="js">++resource++mockup/backdrop/pattern.js</value>
   </records>
 
+  <records prefix="plone.resources/mockup-patterns-cookietrigger"
+            interface='Products.CMFPlone.interfaces.IResourceRegistry'>
+      <value key="js">++resource++mockup/cookietrigger/pattern.js</value>
+  </records>
+
   <records prefix="plone.resources/mockup-patterns-sortable"
             interface='Products.CMFPlone.interfaces.IResourceRegistry'>
       <value key="js">++resource++mockup/sortable/pattern.js</value>
diff --git a/Products/CMFPlone/skins/plone_ecmascript/login.js b/Products/CMFPlone/skins/plone_ecmascript/login.js
deleted file mode 100644
index a66dc13..0000000
--- a/Products/CMFPlone/skins/plone_ecmascript/login.js
+++ /dev/null
@@ -1,74 +0,0 @@
-// Functions used by login pages
-
-function cookiesEnabled() {
-  // Test whether cookies are enabled by attempting to set a cookie and then change its value
-  // set test cookie
-  var c = "areYourCookiesEnabled=0";
-  document.cookie = c;
-  var dc = document.cookie;
-  // cookie not set?  fail
-  if (dc.indexOf(c) == -1) return 0;
-  // change test cookie
-  c = "areYourCookiesEnabled=1";
-  document.cookie = c;
-  dc = document.cookie;
-  // cookie not changed?  fail
-  if (dc.indexOf(c) == -1) return 0;
-  // delete cookie
-  document.cookie = "areYourCookiesEnabled=; expires=Thu, 01-Jan-70 00:00:01 GMT";
-  return 1;
-}
-
-function setLoginVars(user_name_id, alt_user_name_id, password_id, empty_password_id, js_enabled_id, cookies_enabled_id) {
-  // Indicate that javascript is enabled, set cookie status, copy username and password length info to 
-  // alternative variables since these vars are removed from the request by zope's authentication mechanism.
-  if (js_enabled_id) {
-    el = document.getElementById(js_enabled_id);
-    if (el) { el.value = 1; }
-  }
-  if (cookies_enabled_id) {
-    el = document.getElementById(cookies_enabled_id);
-    // Do a fresh cookies enabled test every time we press the login button
-    //   so that we are up to date in case the user enables cookies after seeing
-    //   the cookies message.
-    if (el) { el.value = cookiesEnabled(); } 
-  }
-  if (user_name_id && alt_user_name_id) {
-    user_name = document.getElementById(user_name_id)
-    alt_user_name = document.getElementById(alt_user_name_id)
-    if (user_name && alt_user_name) {
-       alt_user_name.value = user_name.value;
-    } 
-  }
-  if (password_id && empty_password_id) {
-    password = document.getElementById(password_id)
-    empty_password = document.getElementById(empty_password_id)
-    if (password && empty_password) {
-       if (password.value.length==0) {
-          empty_password.value = '1';
-       } else {
-          empty_password.value = '0';
-       }
-    }
-  }
-  return 1;
-}
-
-function showCookieMessage(msg_id) {
-  // Show the element with the given id if cookies are not enabled
-  msg = document.getElementById(msg_id)
-  if (msg) {
-     if (cookiesEnabled()) {
-        msg.style.display = 'none';
-     } else {
-        msg.style.display = 'block';
-     }
-  }
-}
-
-function showEnableCookiesMessage() {
-  // Show the element with the id 'enable_cookies_message' if cookies are not enabled
-  showCookieMessage('enable_cookies_message')
-}
-// Call showEnableCookiesMessage after the page loads
-jQuery(showEnableCookiesMessage);
diff --git a/Products/CMFPlone/skins/plone_login/failsafe_login_form.cpt b/Products/CMFPlone/skins/plone_login/failsafe_login_form.cpt
index 224707e..7a58954 100644
--- a/Products/CMFPlone/skins/plone_login/failsafe_login_form.cpt
+++ b/Products/CMFPlone/skins/plone_login/failsafe_login_form.cpt
@@ -43,9 +43,7 @@ If you do not have an account here, head over to the
 </p>
 
 
-<div class="portalMessage error"
-    id="enable_cookies_message"
-    style="display:none">
+<div class="portalMessage error pat-cookietrigger" style="display:none">
     <strong i18n:translate="">
         Error
     </strong>
diff --git a/Products/CMFPlone/skins/plone_login/logged_out.cpt b/Products/CMFPlone/skins/plone_login/logged_out.cpt
index b05ea0f..e00fbcf 100644
--- a/Products/CMFPlone/skins/plone_login/logged_out.cpt
+++ b/Products/CMFPlone/skins/plone_login/logged_out.cpt
@@ -6,11 +6,6 @@
       i18n:domain="plone">
 
 <head>
-    <metal:js fill-slot="javascript_head_slot">
-        <script type="text/javascript" src=""
-                tal:attributes="src string:${context/portal_url}/login.js">
-        </script>
-    </metal:js>
     <metal:block fill-slot="top_slot"
                  tal:define="dummy python:request.set('disable_border',1);
                              disable_column_one python:request.set('disable_plone.leftcolumn',1);
diff --git a/Products/CMFPlone/skins/plone_login/login_failed.cpt b/Products/CMFPlone/skins/plone_login/login_failed.cpt
index 48a9e0a..6a35335 100644
--- a/Products/CMFPlone/skins/plone_login/login_failed.cpt
+++ b/Products/CMFPlone/skins/plone_login/login_failed.cpt
@@ -7,11 +7,6 @@
       i18n:domain="plone">
 
 <head>
-    <metal:js fill-slot="javascript_head_slot">
-        <script type="text/javascript" src=""
-                tal:attributes="src string:${context/portal_url}/login.js">
-        </script>
-    </metal:js>
     <metal:block fill-slot="top_slot"
                  tal:define="dummy python:request.set('disable_border',1);
                              disable_column_one python:request.set('disable_plone.leftcolumn',1);
diff --git a/Products/CMFPlone/skins/plone_login/login_form.cpt b/Products/CMFPlone/skins/plone_login/login_form.cpt
index 9da9e5a..bbf7c07 100644
--- a/Products/CMFPlone/skins/plone_login/login_form.cpt
+++ b/Products/CMFPlone/skins/plone_login/login_form.cpt
@@ -6,11 +6,6 @@
       i18n:domain="plone">
 
 <head>
-    <metal:js fill-slot="javascript_head_slot">
-        <script type="text/javascript" src=""
-                tal:attributes="src string:${context/portal_url}/login.js">
-        </script>
-    </metal:js>
     <metal:block fill-slot="top_slot"
                  tal:define="dummy python:request.set('disable_border',1);
                              disable_column_one python:request.set('disable_plone.leftcolumn',1);
@@ -55,9 +50,7 @@
                         target python:test(target in ('_parent', '_top', '_blank', '_self'), target, None);
                         ztu modules/ZTUtils;">
 
-            <div class="portalMessage error"
-                id="enable_cookies_message"
-                style="display:none">
+            <div class="portalMessage error pat-cookietrigger" style="display:none">
                 <strong i18n:translate="">
                     Error
                 </strong>
diff --git a/Products/CMFPlone/skins/plone_login/registered.pt b/Products/CMFPlone/skins/plone_login/registered.pt
index 59ac0df..a8fe7e1 100644
--- a/Products/CMFPlone/skins/plone_login/registered.pt
+++ b/Products/CMFPlone/skins/plone_login/registered.pt
@@ -45,9 +45,7 @@
                     Click the button to log in immediately.
                 </p>
 
-                <div class="portalMessage error"
-                    id="enable_cookies_message"
-                    style="display:none">
+                <div class="portalMessage error pat-cookietrigger" style="display:none">
                     <strong i18n:translate="">
                         Error
                     </strong>
diff --git a/Products/CMFPlone/static/plone.js b/Products/CMFPlone/static/plone.js
index b79b820..ab9b442 100644
--- a/Products/CMFPlone/static/plone.js
+++ b/Products/CMFPlone/static/plone.js
@@ -34,6 +34,7 @@ require([
   'plone-patterns-toolbar',
   'mockup-patterns-accessibility',
   'mockup-patterns-autotoc',
+  'mockup-patterns-cookietrigger',
   'mockup-patterns-formunloadalert',
   'mockup-patterns-preventdoublesubmit',
   'mockup-patterns-inlinevalidation',