Repository: mockup
Branch: refs/heads/master
Date: 2014-10-28T16:23:22Z
Author: Peter Holzer (agitator) <hpeter@agitator.com>
Commit: https://github.com/plone/mockup/commit/000576eb0d051ff668a6fb39196ca4c5d4efd3e1

added markspeciallinks pattern

Files changed:
A patterns/markspeciallinks/pattern.js
A patterns/markspeciallinks/pattern.markspeciallinks.less
M js/bundles/docs.js
M js/config.js
M less/docs.less

diff --git a/js/bundles/docs.js b/js/bundles/docs.js
index 43b60e7..331780e 100644
--- a/js/bundles/docs.js
+++ b/js/bundles/docs.js
@@ -57,6 +57,11 @@ require([
             description: 'A pattern to warn user when changes are unsaved and they try to navigate away from page',
             url: 'patterns/formunloadalert/pattern.js'
           },
+          { id: 'markspeciallinks',
+            title: 'Mark special links',
+            description: 'Mark special links based on protocoll and optionally open in new window.',
+            url: 'patterns/markspeciallinks/pattern.js'
+          },
           { id: 'modal',
             title: 'Modal',
             description: 'Creates a modal dialog (also called overlay)',
diff --git a/js/config.js b/js/config.js
index 9ab958e..accba88 100644
--- a/js/config.js
+++ b/js/config.js
@@ -68,6 +68,7 @@
       'mockup-patterns-filemanager-url': 'patterns/filemanager',
       'mockup-patterns-formautofocus': 'patterns/formautofocus/pattern',
       'mockup-patterns-formunloadalert': 'patterns/formunloadalert/pattern',
+      'mockup-patterns-markspeciallinks': 'patterns/markspeciallinks/pattern',
       'mockup-patterns-modal': 'patterns/modal/pattern',
       'mockup-patterns-moment': 'patterns/moment/pattern',
       'mockup-patterns-pickadate': 'patterns/pickadate/pattern',
diff --git a/less/docs.less b/less/docs.less
index 4f20721..33055de 100644
--- a/less/docs.less
+++ b/less/docs.less
@@ -9,6 +9,7 @@
 
 
 @import "../patterns/autotoc/pattern.autotoc.less";
+@import "../patterns/markspeciallinks/pattern.markspeciallinks.less";
 @import "../patterns/modal/pattern.modal.less";
 @import "../patterns/pickadate/pattern.pickadate.less";
 @import "../patterns/querystring/pattern.querystring.less";
diff --git a/patterns/markspeciallinks/pattern.js b/patterns/markspeciallinks/pattern.js
new file mode 100644
index 0000000..2d28d83
--- /dev/null
+++ b/patterns/markspeciallinks/pattern.js
@@ -0,0 +1,121 @@
+/* Mark special links
+ *
+ * Options:
+ *    external_links_open_new_window(boolean): Open external links in a new window. (false)
+ *
+ * Documentation:
+ *   # General
+ *
+ *   Scan all links in the container and mark external links with class
+ *   if they point outside the site, or are special protocols.
+ *   Also implements new window opening for external links.
+ *   To disable this effect for links on a one-by-one-basis,
+ *   give them a class of 'link-plain'
+ *
+ *   # Default external link example
+ *
+ *   {{ example-1 }}
+ *
+ *   # Open external link in new window
+ *
+ *   {{ example-2 }}
+ *
+ *   # List of all protocol icons
+ *
+ *   {{ example-3 }}
+ *
+ * Example: example-1
+ *    <div class="pat-markspeciallinks">
+ *        <p>Find out What's new in <a href="http://www.plone.org">Plone</a>.<br>
+ *           Plone is written in <a class="link-plain" href="http://www.python.org">Python</a>.
+ *        </p>
+ *    </div>
+ *
+ * Example: example-2
+ *    <div class="pat-markspeciallinks" data-pat-markspeciallinks='{"external_links_open_new_window": "true"}'>
+ *        <p>Find out What's new in <a href="http://www.plone.org">Plone</a>.<br>
+ *           Plone is written in <a class="link-plain" href="http://www.python.org">Python</a>.
+ *        </p>
+ *    </div>
+ *
+ * Example: example-3
+ *    <div class="pat-markspeciallinks">
+ *        <ul>
+ *          <li><a href="http://www.plone.org">http</a></li>
+ *          <li><a href="https://www.plone.org">https</a></li>
+ *          <li><a href="mailto:info@plone.org">mailto</a></li>
+ *          <li><a href="ftp://www.plone.org">ftp</a></li>
+ *          <li><a href="news://www.plone.org">news</a></li>
+ *          <li><a href="irc://www.plone.org">irc</a></li>
+ *          <li><a href="h323://www.plone.org">h323</a></li>
+ *          <li><a href="sip://www.plone.org">sip</a></li>
+ *          <li><a href="callto://www.plone.org">callto</a></li>
+ *          <li><a href="feed://www.plone.org">feed</a></li>
+ *          <li><a href="webcal://www.plone.org">webcal</a></li>
+ *        </ul>
+ *    </div>
+ *
+ */
+
+define([
+  'mockup-patterns-base',
+  'jquery'
+], function (Base, $) {
+  'use strict';
+
+  var MarkSpecialLinks = Base.extend({
+    name: 'markspeciallinks',
+    defaults: {
+      external_links_open_new_window: false
+    },
+    init: function () {
+      var self = this, $el = self.$el;
+
+      // first make external links open in a new window, afterwards do the
+      // normal plone link wrapping in only the content area
+      var elonw,
+          url,
+          protocols,
+          contentarea,
+          res;
+
+      if (typeof self.options.external_links_open_new_window === 'string') {
+          elonw = self.options.external_links_open_new_window.toLowerCase() === 'true';
+      } else {
+          elonw = false;
+      }
+
+      url = window.location.protocol + '//' + window.location.host;
+      protocols = /^(mailto|ftp|news|irc|h323|sip|callto|https|feed|webcal)/;
+      contentarea = $el;
+
+      if (elonw) {
+          // all http links (without the link-plain class), not within this site
+          contentarea.find('a[href^="http"]:not(.link-plain):not([href^="' + url + '"])')
+                     .attr('target', '_blank');
+      }
+
+      // All links with an http href (without the link-plain class), not within this site,
+      // and no img children should be wrapped in a link-external span
+      contentarea.find(
+          'a[href^="http:"]:not(.link-plain):not([href^="' + url + '"]):not(:has(img))')
+          .before('<i class="glyphicon link-external"></i>');
+      // All links without an http href (without the link-plain class), not within this site,
+      // and no img children should be wrapped in a link-[protocol] span
+      contentarea.find(
+          'a[href]:not([href^="http:"]):not(.link-plain):not([href^="' + url + '"]):not(:has(img))')
+          .each(function() {
+              // those without a http link may have another interesting protocol
+              // wrap these in a link-[protocol] span
+              res = protocols.exec(this.href);
+              if (res) {
+                  var iconclass = 'glyphicon link-' + res[0];
+                  jQuery(this).before('<i class="' + iconclass + '"></i>');
+              }
+          }
+      );
+
+    }
+  });
+  return MarkSpecialLinks;
+});
diff --git a/patterns/markspeciallinks/pattern.markspeciallinks.less b/patterns/markspeciallinks/pattern.markspeciallinks.less
new file mode 100644
index 0000000..f522b0e
--- /dev/null
+++ b/patterns/markspeciallinks/pattern.markspeciallinks.less
@@ -0,0 +1,36 @@
+i.glyphicon {
+    padding-right: 0.1em;
+}
+i.link-external:after {
+    content: "\e144";
+}
+i.link-mailto:after {
+    content: "\2709";
+}
+i.link-ftp:after {
+    content: "\e121";
+}
+i.link-news:after {
+    content: "\e135";
+}
+i.link-irc:after {
+    content: "\e122";
+}
+i.link-h323:after {
+    content: "\e059";
+}
+i.link-sip:after {
+    content: "\e035";
+}
+i.link-callto:after {
+    content: "\e145";
+}
+i.link-https:after {
+    content: "\e033";
+}
+i.link-feed:after {
+    content: "\e056";
+}
+i.link-webcal:after {
+    content: "\E109";
+}
\ No newline at end of file


Repository: mockup
Branch: refs/heads/master
Date: 2014-10-28T17:50:25Z
Author: Peter Holzer (agitator) <hpeter@agitator.com>
Commit: https://github.com/plone/mockup/commit/96539f8432e4ed4ed946ad434023623e25cfd4ae

added tests to markspeciallinks pattern

Files changed:
A tests/pattern-markspeciallinks-test.js

diff --git a/tests/pattern-markspeciallinks-test.js b/tests/pattern-markspeciallinks-test.js
new file mode 100644
index 0000000..6569eac
--- /dev/null
+++ b/tests/pattern-markspeciallinks-test.js
@@ -0,0 +1,71 @@
+define([
+  'expect',
+  'jquery',
+  'mockup-registry',
+  'mockup-patterns-markspeciallinks'
+], function(expect, $, registry, MarkSpecialLinks) {
+  'use strict';
+
+  window.mocha.setup('bdd');
+  $.fx.off = true;
+
+/* ==========================
+   TEST: MarkSpecialLinks
+  ========================== */
+
+  describe('MarkSpecialLinks', function () {
+    beforeEach(function() {
+      this.$el = $ ('' +
+        '<div class="pat-markspeciallinks">' +
+        '  <p>Find out What&#39s new in <a href="http://www.plone.org">Plone</a>.<br>' +
+        '     Plone is written in <a class="link-plain" href="http://www.python.org">Python</a>.' +
+        '  </p>' +
+        '</div>' +
+        '<div class="pat-markspeciallinks" data-pat-markspeciallinks="external_links_open_new_window: true">' +
+        '  <p>Find out What&#39s new in <a href="http://www.plone.org">Plone</a>.<br>' +
+        '     Plone is written in <a class="link-plain" href="http://www.python.org">Python</a>.' +
+        '  </p>' +
+        '</div>' +
+        '<div class="icons pat-markspeciallinks">' +
+        '    <ul>' +
+        '      <li><a href="http://www.plone.org">http</a></li>' +
+        '      <li><a href="https://www.plone.org">https</a></li>' +
+        '      <li><a href="mailto:info@plone.org">mailto</a></li>' +
+        '      <li><a href="ftp://www.plone.org">ftp</a></li>' +
+        '      <li><a href="news://www.plone.org">news</a></li>' +
+        '      <li><a href="irc://www.plone.org">irc</a></li>' +
+        '      <li><a href="h323://www.plone.org">h323</a></li>' +
+        '      <li><a href="sip://www.plone.org">sip</a></li>' +
+        '      <li><a href="callto://www.plone.org">callto</a></li>' +
+        '      <li><a href="feed://www.plone.org">feed</a></li>' +
+        '      <li><a href="webcal://www.plone.org">webcal</a></li>' +
+        '    </ul>' +
+        '</div>');
+
+
+    });
+    it('normal external links have target=_blank', function() {
+      registry.scan(this.$el);
+      var link = this.$el.find('a');
+      expect(link.eq(0).attr("target")===undefined).to.be.equal(true);
+      expect(link.eq(1).attr("target")===undefined).to.be.equal(true);
+      expect(link.eq(2).attr("target")).to.be.equal("_blank");
+      expect(link.eq(3).attr("target")===undefined).to.be.equal(true);
+    });
+    it('check for correct icon classes per protocol', function() {
+      registry.scan(this.$el);
+      var listel = this.$el.next('.icons').find('li');
+      expect(listel.eq(0).find("i").hasClass('link-external')).to.be.equal(true);
+      expect(listel.eq(1).find("i").hasClass('link-https')).to.be.equal(true);
+      expect(listel.eq(2).find("i").hasClass('link-mailto')).to.be.equal(true);
+      expect(listel.eq(3).find("i").hasClass('link-ftp')).to.be.equal(true);
+      expect(listel.eq(4).find("i").hasClass('link-news')).to.be.equal(true);
+      expect(listel.eq(5).find("i").hasClass('link-irc')).to.be.equal(true);
+      expect(listel.eq(6).find("i").hasClass('link-h323')).to.be.equal(true);
+      expect(listel.eq(7).find("i").hasClass('link-sip')).to.be.equal(true);
+      expect(listel.eq(8).find("i").hasClass('link-callto')).to.be.equal(true);
+      expect(listel.eq(9).find("i").hasClass('link-feed')).to.be.equal(true);
+      expect(listel.eq(10).find("i").hasClass('link-webcal')).to.be.equal(true);
+    });
+  });
+});


Repository: mockup
Branch: refs/heads/master
Date: 2014-11-28T11:47:41+01:00
Author: Johannes Raggam (thet) <raggam-nl@adm.at>
Commit: https://github.com/plone/mockup/commit/c3b64843f913131836a09d6fde50263358d4ec3b

merge markspeciallinks

Files changed:
A mockup/patterns/markspeciallinks/pattern.js
A mockup/patterns/markspeciallinks/pattern.markspeciallinks.less
A mockup/tests/pattern-markspeciallinks-test.js
M CHANGES.rst
M mockup/js/bundles/docs.js
M mockup/js/config.js
M mockup/less/docs.less

diff --git a/CHANGES.rst b/CHANGES.rst
index 30b840f..d4d1add 100644
--- a/CHANGES.rst
+++ b/CHANGES.rst
@@ -6,6 +6,9 @@ Changelog
 
 New patterns:
 
+- Add "markspeciallinks" pattern.
+  [agitator, fulv]
+
 - Add mimetype selector pattern for textareas.
   [thet]
 
diff --git a/mockup/js/bundles/docs.js b/mockup/js/bundles/docs.js
index 94f6d0e..2a5961a 100644
--- a/mockup/js/bundles/docs.js
+++ b/mockup/js/bundles/docs.js
@@ -67,6 +67,11 @@ require([
             description: 'Client side validation of form fields',
             url: 'patterns/inlinevalidation/pattern.js'
           },
+          { id: 'markspeciallinks',
+            title: 'Mark special links',
+            description: 'Mark special links based on protocoll and optionally open in new window.',
+            url: 'patterns/markspeciallinks/pattern.js'
+          },
           { id: 'modal',
             title: 'Modal',
             description: 'Creates a modal dialog (also called overlay)',
diff --git a/mockup/js/config.js b/mockup/js/config.js
index 1cb9500..bd58bf7 100644
--- a/mockup/js/config.js
+++ b/mockup/js/config.js
@@ -70,6 +70,7 @@
       'mockup-patterns-formautofocus': 'patterns/formautofocus/pattern',
       'mockup-patterns-formunloadalert': 'patterns/formunloadalert/pattern',
       'mockup-patterns-inlinevalidation': 'patterns/inlinevalidation/pattern',
+      'mockup-patterns-markspeciallinks': 'patterns/markspeciallinks/pattern',
       'mockup-patterns-modal': 'patterns/modal/pattern',
       'mockup-patterns-moment': 'patterns/moment/pattern',
       'mockup-patterns-pickadate': 'patterns/pickadate/pattern',
diff --git a/mockup/less/docs.less b/mockup/less/docs.less
index d38579d..fc66ac6 100644
--- a/mockup/less/docs.less
+++ b/mockup/less/docs.less
@@ -9,6 +9,7 @@
 
 
 @import "../patterns/autotoc/pattern.autotoc.less";
+@import "../patterns/markspeciallinks/pattern.markspeciallinks.less";
 @import "../patterns/modal/pattern.modal.less";
 @import "../patterns/pickadate/pattern.pickadate.less";
 @import "../patterns/querystring/pattern.querystring.less";
diff --git a/mockup/patterns/markspeciallinks/pattern.js b/mockup/patterns/markspeciallinks/pattern.js
new file mode 100644
index 0000000..2d28d83
--- /dev/null
+++ b/mockup/patterns/markspeciallinks/pattern.js
@@ -0,0 +1,121 @@
+/* Mark special links
+ *
+ * Options:
+ *    external_links_open_new_window(boolean): Open external links in a new window. (false)
+ *
+ * Documentation:
+ *   # General
+ *
+ *   Scan all links in the container and mark external links with class
+ *   if they point outside the site, or are special protocols.
+ *   Also implements new window opening for external links.
+ *   To disable this effect for links on a one-by-one-basis,
+ *   give them a class of 'link-plain'
+ *
+ *   # Default external link example
+ *
+ *   {{ example-1 }}
+ *
+ *   # Open external link in new window
+ *
+ *   {{ example-2 }}
+ *
+ *   # List of all protocol icons
+ *
+ *   {{ example-3 }}
+ *
+ * Example: example-1
+ *    <div class="pat-markspeciallinks">
+ *        <p>Find out What's new in <a href="http://www.plone.org">Plone</a>.<br>
+ *           Plone is written in <a class="link-plain" href="http://www.python.org">Python</a>.
+ *        </p>
+ *    </div>
+ *
+ * Example: example-2
+ *    <div class="pat-markspeciallinks" data-pat-markspeciallinks='{"external_links_open_new_window": "true"}'>
+ *        <p>Find out What's new in <a href="http://www.plone.org">Plone</a>.<br>
+ *           Plone is written in <a class="link-plain" href="http://www.python.org">Python</a>.
+ *        </p>
+ *    </div>
+ *
+ * Example: example-3
+ *    <div class="pat-markspeciallinks">
+ *        <ul>
+ *          <li><a href="http://www.plone.org">http</a></li>
+ *          <li><a href="https://www.plone.org">https</a></li>
+ *          <li><a href="mailto:info@plone.org">mailto</a></li>
+ *          <li><a href="ftp://www.plone.org">ftp</a></li>
+ *          <li><a href="news://www.plone.org">news</a></li>
+ *          <li><a href="irc://www.plone.org">irc</a></li>
+ *          <li><a href="h323://www.plone.org">h323</a></li>
+ *          <li><a href="sip://www.plone.org">sip</a></li>
+ *          <li><a href="callto://www.plone.org">callto</a></li>
+ *          <li><a href="feed://www.plone.org">feed</a></li>
+ *          <li><a href="webcal://www.plone.org">webcal</a></li>
+ *        </ul>
+ *    </div>
+ *
+ */
+
+define([
+  'mockup-patterns-base',
+  'jquery'
+], function (Base, $) {
+  'use strict';
+
+  var MarkSpecialLinks = Base.extend({
+    name: 'markspeciallinks',
+    defaults: {
+      external_links_open_new_window: false
+    },
+    init: function () {
+      var self = this, $el = self.$el;
+
+      // first make external links open in a new window, afterwards do the
+      // normal plone link wrapping in only the content area
+      var elonw,
+          url,
+          protocols,
+          contentarea,
+          res;
+
+      if (typeof self.options.external_links_open_new_window === 'string') {
+          elonw = self.options.external_links_open_new_window.toLowerCase() === 'true';
+      } else {
+          elonw = false;
+      }
+
+      url = window.location.protocol + '//' + window.location.host;
+      protocols = /^(mailto|ftp|news|irc|h323|sip|callto|https|feed|webcal)/;
+      contentarea = $el;
+
+      if (elonw) {
+          // all http links (without the link-plain class), not within this site
+          contentarea.find('a[href^="http"]:not(.link-plain):not([href^="' + url + '"])')
+                     .attr('target', '_blank');
+      }
+
+      // All links with an http href (without the link-plain class), not within this site,
+      // and no img children should be wrapped in a link-external span
+      contentarea.find(
+          'a[href^="http:"]:not(.link-plain):not([href^="' + url + '"]):not(:has(img))')
+          .before('<i class="glyphicon link-external"></i>');
+      // All links without an http href (without the link-plain class), not within this site,
+      // and no img children should be wrapped in a link-[protocol] span
+      contentarea.find(
+          'a[href]:not([href^="http:"]):not(.link-plain):not([href^="' + url + '"]):not(:has(img))')
+          .each(function() {
+              // those without a http link may have another interesting protocol
+              // wrap these in a link-[protocol] span
+              res = protocols.exec(this.href);
+              if (res) {
+                  var iconclass = 'glyphicon link-' + res[0];
+                  jQuery(this).before('<i class="' + iconclass + '"></i>');
+              }
+          }
+      );
+
+    }
+  });
+  return MarkSpecialLinks;
+});
diff --git a/mockup/patterns/markspeciallinks/pattern.markspeciallinks.less b/mockup/patterns/markspeciallinks/pattern.markspeciallinks.less
new file mode 100644
index 0000000..f522b0e
--- /dev/null
+++ b/mockup/patterns/markspeciallinks/pattern.markspeciallinks.less
@@ -0,0 +1,36 @@
+i.glyphicon {
+    padding-right: 0.1em;
+}
+i.link-external:after {
+    content: "\e144";
+}
+i.link-mailto:after {
+    content: "\2709";
+}
+i.link-ftp:after {
+    content: "\e121";
+}
+i.link-news:after {
+    content: "\e135";
+}
+i.link-irc:after {
+    content: "\e122";
+}
+i.link-h323:after {
+    content: "\e059";
+}
+i.link-sip:after {
+    content: "\e035";
+}
+i.link-callto:after {
+    content: "\e145";
+}
+i.link-https:after {
+    content: "\e033";
+}
+i.link-feed:after {
+    content: "\e056";
+}
+i.link-webcal:after {
+    content: "\E109";
+}
\ No newline at end of file
diff --git a/mockup/tests/pattern-markspeciallinks-test.js b/mockup/tests/pattern-markspeciallinks-test.js
new file mode 100644
index 0000000..6569eac
--- /dev/null
+++ b/mockup/tests/pattern-markspeciallinks-test.js
@@ -0,0 +1,71 @@
+define([
+  'expect',
+  'jquery',
+  'mockup-registry',
+  'mockup-patterns-markspeciallinks'
+], function(expect, $, registry, MarkSpecialLinks) {
+  'use strict';
+
+  window.mocha.setup('bdd');
+  $.fx.off = true;
+
+/* ==========================
+   TEST: MarkSpecialLinks
+  ========================== */
+
+  describe('MarkSpecialLinks', function () {
+    beforeEach(function() {
+      this.$el = $ ('' +
+        '<div class="pat-markspeciallinks">' +
+        '  <p>Find out What&#39s new in <a href="http://www.plone.org">Plone</a>.<br>' +
+        '     Plone is written in <a class="link-plain" href="http://www.python.org">Python</a>.' +
+        '  </p>' +
+        '</div>' +
+        '<div class="pat-markspeciallinks" data-pat-markspeciallinks="external_links_open_new_window: true">' +
+        '  <p>Find out What&#39s new in <a href="http://www.plone.org">Plone</a>.<br>' +
+        '     Plone is written in <a class="link-plain" href="http://www.python.org">Python</a>.' +
+        '  </p>' +
+        '</div>' +
+        '<div class="icons pat-markspeciallinks">' +
+        '    <ul>' +
+        '      <li><a href="http://www.plone.org">http</a></li>' +
+        '      <li><a href="https://www.plone.org">https</a></li>' +
+        '      <li><a href="mailto:info@plone.org">mailto</a></li>' +
+        '      <li><a href="ftp://www.plone.org">ftp</a></li>' +
+        '      <li><a href="news://www.plone.org">news</a></li>' +
+        '      <li><a href="irc://www.plone.org">irc</a></li>' +
+        '      <li><a href="h323://www.plone.org">h323</a></li>' +
+        '      <li><a href="sip://www.plone.org">sip</a></li>' +
+        '      <li><a href="callto://www.plone.org">callto</a></li>' +
+        '      <li><a href="feed://www.plone.org">feed</a></li>' +
+        '      <li><a href="webcal://www.plone.org">webcal</a></li>' +
+        '    </ul>' +
+        '</div>');
+
+
+    });
+    it('normal external links have target=_blank', function() {
+      registry.scan(this.$el);
+      var link = this.$el.find('a');
+      expect(link.eq(0).attr("target")===undefined).to.be.equal(true);
+      expect(link.eq(1).attr("target")===undefined).to.be.equal(true);
+      expect(link.eq(2).attr("target")).to.be.equal("_blank");
+      expect(link.eq(3).attr("target")===undefined).to.be.equal(true);
+    });
+    it('check for correct icon classes per protocol', function() {
+      registry.scan(this.$el);
+      var listel = this.$el.next('.icons').find('li');
+      expect(listel.eq(0).find("i").hasClass('link-external')).to.be.equal(true);
+      expect(listel.eq(1).find("i").hasClass('link-https')).to.be.equal(true);
+      expect(listel.eq(2).find("i").hasClass('link-mailto')).to.be.equal(true);
+      expect(listel.eq(3).find("i").hasClass('link-ftp')).to.be.equal(true);
+      expect(listel.eq(4).find("i").hasClass('link-news')).to.be.equal(true);
+      expect(listel.eq(5).find("i").hasClass('link-irc')).to.be.equal(true);
+      expect(listel.eq(6).find("i").hasClass('link-h323')).to.be.equal(true);
+      expect(listel.eq(7).find("i").hasClass('link-sip')).to.be.equal(true);
+      expect(listel.eq(8).find("i").hasClass('link-callto')).to.be.equal(true);
+      expect(listel.eq(9).find("i").hasClass('link-feed')).to.be.equal(true);
+      expect(listel.eq(10).find("i").hasClass('link-webcal')).to.be.equal(true);
+    });
+  });
+});


Repository: mockup
Branch: refs/heads/master
Date: 2014-11-28T12:15:13+01:00
Author: Johannes Raggam (thet) <raggam-nl@adm.at>
Commit: https://github.com/plone/mockup/commit/06de78cf6dcc82e8b3d36ae77792e21d80fb9a80

some more doc examples (external after link-plain + internal link)

Files changed:
M mockup/patterns/markspeciallinks/pattern.js

diff --git a/mockup/patterns/markspeciallinks/pattern.js b/mockup/patterns/markspeciallinks/pattern.js
index 2d28d83..473a19e 100644
--- a/mockup/patterns/markspeciallinks/pattern.js
+++ b/mockup/patterns/markspeciallinks/pattern.js
@@ -26,16 +26,22 @@
  *
  * Example: example-1
  *    <div class="pat-markspeciallinks">
- *        <p>Find out What's new in <a href="http://www.plone.org">Plone</a>.<br>
- *           Plone is written in <a class="link-plain" href="http://www.python.org">Python</a>.
- *        </p>
+ *      <ul>
+ *        <li>Find out What's new in <a href="http://www.plone.org">Plone</a>.</li>
+ *        <li>Plone is written in <a class="link-plain" href="http://www.python.org">Python</a>.</li>
+ *        <li>Plone builds on <a href="http://zope.org">Zope</a>.</li>
+ *        <li>Plone uses <a href="/">Mockup</a>.</li>
+ *      </ul>
  *    </div>
  *
  * Example: example-2
  *    <div class="pat-markspeciallinks" data-pat-markspeciallinks='{"external_links_open_new_window": "true"}'>
- *        <p>Find out What's new in <a href="http://www.plone.org">Plone</a>.<br>
- *           Plone is written in <a class="link-plain" href="http://www.python.org">Python</a>.
- *        </p>
+ *      <ul>
+ *        <li>Find out What's new in <a href="http://www.plone.org">Plone</a>.</li>
+ *        <li>Plone is written in <a class="link-plain" href="http://www.python.org">Python</a>.</li>
+ *        <li>Plone builds on <a href="http://zope.org">Zope</a>.</li>
+ *        <li>Plone uses <a href="/">Mockup</a>.</li>
+ *      </ul>
  *    </div>
  *
  * Example: example-3


Repository: mockup
Branch: refs/heads/master
Date: 2014-11-28T12:15:37+01:00
Author: Johannes Raggam (thet) <raggam-nl@adm.at>
Commit: https://github.com/plone/mockup/commit/21cf2fa1149d6973c0e8fe7b12ee5458b58b1102

Merge branch 'master' into tmp-markspeciallinks

Files changed:
M CHANGES.rst
M mockup/patterns/modal/pattern.js
M mockup/tests/pattern-modal-test.js

diff --git a/CHANGES.rst b/CHANGES.rst
index d4d1add..292809c 100644
--- a/CHANGES.rst
+++ b/CHANGES.rst
@@ -26,6 +26,11 @@ New patterns:
 
 Fixes and enhancements:
 
+- Modal Pattern: If ``data-base-url`` attribute is available on the body, use
+  it. Otherwise search for a ``<base>`` tag. Plone 5 dropped the usage of base
+  tags.
+  [ACatlla, thet]
+
 - Depend on ``tinymce-builded`` 4.1.6, include TinyMCE copy and sed
   configuration in here and fix some sed tasks.
   Revert cd89d377e10a28b797fd3c9d48410ad6ad597486: "Remove bower dependency on
diff --git a/mockup/patterns/modal/pattern.js b/mockup/patterns/modal/pattern.js
index 66387d1..5f1c3e1 100644
--- a/mockup/patterns/modal/pattern.js
+++ b/mockup/patterns/modal/pattern.js
@@ -156,7 +156,19 @@ define([
         onTimeout: null,
         redirectOnResponse: false,
         redirectToUrl: function($action, response, options) {
-          return $('body').data('base-url');
+          var baseUrl = '';
+          var reg = /<body.*data-base-url=[\"'](.*)[\"'].*/im.exec(response);
+          if (reg && reg.length > 1) {
+            // Base url as data attribute on body (Plone 5)
+            baseUrl = reg[1];
+          } else {
+            reg = /<base.*href=[\"'](.*)[\"'].*/im.exec(response);
+            if (reg && reg.length > 1) {
+              // base tag available (Plone 4)
+              baseUrl = reg[1];
+            }
+          }
+          return baseUrl;
         }
       },
       routerOptions: {
diff --git a/mockup/tests/pattern-modal-test.js b/mockup/tests/pattern-modal-test.js
index cb6e17e..21acaa4 100644
--- a/mockup/tests/pattern-modal-test.js
+++ b/mockup/tests/pattern-modal-test.js
@@ -136,12 +136,16 @@ define([
           var modal = $(this).data('pattern-modal');
           expect(modal.defaults.actionOptions.redirectToUrl(
             'ignore',
-            '<html><head><base href="testurl"></base></head></html>'
-          )).to.equal('testurl');
+            '<html><head><base href="testurl1"></base></head></html>'
+          )).to.equal('testurl1');
           expect(modal.defaults.actionOptions.redirectToUrl(
             'ignore',
-            '<html><head><base href="testurl" /></head></html>'
-          )).to.equal('testurl');
+            '<html><head><base href="testurl2" /></head></html>'
+          )).to.equal('testurl2');
+          expect(modal.defaults.actionOptions.redirectToUrl(
+            'ignore',
+            '<html><body data-base-url="testurl3"></body></html>'
+          )).to.equal('testurl3');
           done();
         })
         .click();