Commits

timger K committed 7837125

add confirm

Comments (0)

Files changed (6)

bootstrap-modal.js

+/* =========================================================
+ * bootstrap-modal.js v1.3.0
+ * http://twitter.github.com/bootstrap/javascript.html#modal
+ * =========================================================
+ * Copyright 2011 Twitter, Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ========================================================= */
+
+
+!function( $ ){
+
+ /* CSS TRANSITION SUPPORT (https://gist.github.com/373874)
+  * ======================================================= */
+
+  var transitionEnd
+
+  $(document).ready(function () {
+
+    $.support.transition = (function () {
+      var thisBody = document.body || document.documentElement
+        , thisStyle = thisBody.style
+        , support = thisStyle.transition !== undefined || thisStyle.WebkitTransition !== undefined || thisStyle.MozTransition !== undefined || thisStyle.MsTransition !== undefined || thisStyle.OTransition !== undefined
+      return support
+    })()
+
+    // set CSS transition event type
+    if ( $.support.transition ) {
+      transitionEnd = "TransitionEnd"
+      if ( $.browser.webkit ) {
+      	transitionEnd = "webkitTransitionEnd"
+      } else if ( $.browser.mozilla ) {
+      	transitionEnd = "transitionend"
+      } else if ( $.browser.opera ) {
+      	transitionEnd = "oTransitionEnd"
+      }
+    }
+
+  })
+
+
+ /* MODAL PUBLIC CLASS DEFINITION
+  * ============================= */
+
+  var Modal = function ( content, options ) {
+    this.settings = $.extend({}, $.fn.modal.defaults, options)
+    this.$element = $(content)
+      .delegate('.close', 'click.modal', $.proxy(this.hide, this))
+
+    if ( this.settings.show ) {
+      this.show()
+    }
+
+    return this
+  }
+
+  Modal.prototype = {
+
+      toggle: function () {
+        return this[!this.isShown ? 'show' : 'hide']()
+      }
+
+    , show: function () {
+        var that = this
+        this.isShown = true
+        this.$element.trigger('show')
+
+        escape.call(this)
+        backdrop.call(this, function () {
+          var transition = $.support.transition && that.$element.hasClass('fade')
+
+          that.$element
+            .appendTo(document.body)
+            .show()
+
+          if (transition) {
+            that.$element[0].offsetWidth // force reflow
+          }
+
+          that.$element
+            .addClass('in')
+
+          transition ?
+            that.$element.one(transitionEnd, function () { that.$element.trigger('shown') }) :
+            that.$element.trigger('shown')
+
+        })
+
+        return this
+      }
+
+    , hide: function (e) {
+        e && e.preventDefault()
+
+        if ( !this.isShown ) {
+          return this
+        }
+
+        var that = this
+        this.isShown = false
+
+        escape.call(this)
+
+        this.$element
+          .trigger('hide')
+          .removeClass('in')
+
+        function removeElement () {
+          that.$element
+            .hide()
+            .trigger('hidden')
+
+          backdrop.call(that)
+        }
+
+        $.support.transition && this.$element.hasClass('fade') ?
+          this.$element.one(transitionEnd, removeElement) :
+          removeElement()
+
+        return this
+      }
+
+  }
+
+
+ /* MODAL PRIVATE METHODS
+  * ===================== */
+
+  function backdrop ( callback ) {
+    var that = this
+      , animate = this.$element.hasClass('fade') ? 'fade' : ''
+    if ( this.isShown && this.settings.backdrop ) {
+      var doAnimate = $.support.transition && animate
+
+      this.$backdrop = $('<div class="modal-backdrop ' + animate + '" />')
+        .appendTo(document.body)
+
+      if ( this.settings.backdrop != 'static' ) {
+        this.$backdrop.click($.proxy(this.hide, this))
+      }
+
+      if ( doAnimate ) {
+        this.$backdrop[0].offsetWidth // force reflow
+      }
+
+      this.$backdrop.addClass('in')
+
+      doAnimate ?
+        this.$backdrop.one(transitionEnd, callback) :
+        callback()
+
+    } else if ( !this.isShown && this.$backdrop ) {
+      this.$backdrop.removeClass('in')
+
+      function removeElement() {
+        that.$backdrop.remove()
+        that.$backdrop = null
+      }
+
+      $.support.transition && this.$element.hasClass('fade')?
+        this.$backdrop.one(transitionEnd, removeElement) :
+        removeElement()
+    } else if ( callback ) {
+       callback()
+    }
+  }
+
+  function escape() {
+    var that = this
+    if ( this.isShown && this.settings.keyboard ) {
+      $(document).bind('keyup.modal', function ( e ) {
+        if ( e.which == 27 ) {
+          that.hide()
+        }
+      })
+    } else if ( !this.isShown ) {
+      $(document).unbind('keyup.modal')
+    }
+  }
+
+
+ /* MODAL PLUGIN DEFINITION
+  * ======================= */
+
+  $.fn.modal = function ( options ) {
+    var modal = this.data('modal')
+
+    if (!modal) {
+
+      if (typeof options == 'string') {
+        options = {
+          show: /show|toggle/.test(options)
+        }
+      }
+
+      return this.each(function () {
+        $(this).data('modal', new Modal(this, options))
+      })
+    }
+
+    if ( options === true ) {
+      return modal
+    }
+
+    if ( typeof options == 'string' ) {
+      modal[options]()
+    } else if ( modal ) {
+      modal.toggle()
+    }
+
+    return this
+  }
+
+  $.fn.modal.Modal = Modal
+
+  $.fn.modal.defaults = {
+    backdrop: false
+  , keyboard: false
+  , show: false
+  }
+
+
+ /* MODAL DATA- IMPLEMENTATION
+  * ========================== */
+
+  $(document).ready(function () {
+    $('body').delegate('[data-controls-modal]', 'click', function (e) {
+      e.preventDefault()
+      var $this = $(this).data('show', true)
+      $('#' + $this.attr('data-controls-modal')).modal( $this.data() )
+    })
+  })
+
+}( window.jQuery || window.ender );

bootstrap-twipsy.js

+/* ==========================================================
+ * bootstrap-twipsy.js v1.3.0
+ * http://twitter.github.com/bootstrap/javascript.html#twipsy
+ * Adapted from the original jQuery.tipsy by Jason Frame
+ * ==========================================================
+ * Copyright 2011 Twitter, Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ========================================================== */
+
+
+!function( $ ) {
+
+ /* CSS TRANSITION SUPPORT (https://gist.github.com/373874)
+  * ======================================================= */
+
+  var transitionEnd
+
+  $(document).ready(function () {
+
+    $.support.transition = (function () {
+      var thisBody = document.body || document.documentElement
+        , thisStyle = thisBody.style
+        , support = thisStyle.transition !== undefined || thisStyle.WebkitTransition !== undefined || thisStyle.MozTransition !== undefined || thisStyle.MsTransition !== undefined || thisStyle.OTransition !== undefined
+      return support
+    })()
+
+    // set CSS transition event type
+    if ( $.support.transition ) {
+      transitionEnd = "TransitionEnd"
+      if ( $.browser.webkit ) {
+      	transitionEnd = "webkitTransitionEnd"
+      } else if ( $.browser.mozilla ) {
+      	transitionEnd = "transitionend"
+      } else if ( $.browser.opera ) {
+      	transitionEnd = "oTransitionEnd"
+      }
+    }
+
+  })
+
+
+ /* TWIPSY PUBLIC CLASS DEFINITION
+  * ============================== */
+
+  var Twipsy = function ( element, options ) {
+    this.$element = $(element)
+    this.options = options
+    this.enabled = true
+    this.fixTitle()
+  }
+
+  Twipsy.prototype = {
+
+    show: function() {
+      var pos
+        , actualWidth
+        , actualHeight
+        , placement
+        , $tip
+        , tp
+
+      if (this.getTitle() && this.enabled) {
+        $tip = this.tip()
+        this.setContent()
+
+        if (this.options.animate) {
+          $tip.addClass('fade')
+        }
+
+        $tip
+          .remove()
+          .css({ top: 0, left: 0, display: 'block' })
+          .prependTo(document.body)
+
+        pos = $.extend({}, this.$element.offset(), {
+          width: this.$element[0].offsetWidth
+        , height: this.$element[0].offsetHeight
+        })
+
+        actualWidth = $tip[0].offsetWidth
+        actualHeight = $tip[0].offsetHeight
+
+        placement = maybeCall(this.options.placement, this, [ $tip[0], this.$element[0] ])
+
+        switch (placement) {
+          case 'below':
+            tp = {top: pos.top + pos.height + this.options.offset, left: pos.left + pos.width / 2 - actualWidth / 2}
+            break
+          case 'above':
+            tp = {top: pos.top - actualHeight - this.options.offset, left: pos.left + pos.width / 2 - actualWidth / 2}
+            break
+          case 'left':
+            tp = {top: pos.top + pos.height / 2 - actualHeight / 2, left: pos.left - actualWidth - this.options.offset}
+            break
+          case 'right':
+            tp = {top: pos.top + pos.height / 2 - actualHeight / 2, left: pos.left + pos.width + this.options.offset}
+            break
+        }
+
+        $tip
+          .css(tp)
+          .addClass(placement)
+          .addClass('in')
+      }
+    }
+
+  , setContent: function () {
+      var $tip = this.tip()
+      $tip.find('.twipsy-inner')[this.options.html ? 'html' : 'text'](this.getTitle())
+      $tip[0].className = 'twipsy'
+    }
+
+  , hide: function() {
+      var that = this
+        , $tip = this.tip()
+
+      $tip.removeClass('in')
+
+      function removeElement () {
+        $tip.remove()
+      }
+
+      $.support.transition && this.$tip.hasClass('fade') ?
+        $tip.bind(transitionEnd, removeElement) :
+        removeElement()
+    }
+
+  , fixTitle: function() {
+      var $e = this.$element
+      if ($e.attr('title') || typeof($e.attr('data-original-title')) != 'string') {
+        $e.attr('data-original-title', $e.attr('title') || '').removeAttr('title')
+      }
+    }
+
+  , getTitle: function() {
+      var title
+        , $e = this.$element
+        , o = this.options
+
+        this.fixTitle()
+
+        if (typeof o.title == 'string') {
+          title = $e.attr(o.title == 'title' ? 'data-original-title' : o.title)
+        } else if (typeof o.title == 'function') {
+          title = o.title.call($e[0])
+        }
+
+        title = ('' + title).replace(/(^\s*|\s*$)/, "")
+
+        return title || o.fallback
+    }
+
+  , tip: function() {
+      if (!this.$tip) {
+        this.$tip = $('<div class="twipsy" />').html('<div class="twipsy-arrow"></div><div class="twipsy-inner"></div>')
+      }
+      return this.$tip
+    }
+
+  , validate: function() {
+      if (!this.$element[0].parentNode) {
+        this.hide()
+        this.$element = null
+        this.options = null
+      }
+    }
+
+  , enable: function() {
+      this.enabled = true
+    }
+
+  , disable: function() {
+      this.enabled = false
+    }
+
+  , toggleEnabled: function() {
+      this.enabled = !this.enabled
+    }
+
+  }
+
+
+ /* TWIPSY PRIVATE METHODS
+  * ====================== */
+
+   function maybeCall ( thing, ctx, args ) {
+     return typeof thing == 'function' ? thing.apply(ctx, args) : thing
+   }
+
+ /* TWIPSY PLUGIN DEFINITION
+  * ======================== */
+
+  $.fn.twipsy = function (options) {
+    $.fn.twipsy.initWith.call(this, options, Twipsy, 'twipsy')
+    return this
+  }
+
+  $.fn.twipsy.initWith = function (options, Constructor, name) {
+    var twipsy
+      , binder
+      , eventIn
+      , eventOut
+
+    if (options === true) {
+      return this.data(name)
+    } else if (typeof options == 'string') {
+      twipsy = this.data(name)
+      if (twipsy) {
+        twipsy[options]()
+      }
+      return this
+    }
+
+    options = $.extend({}, $.fn[name].defaults, options)
+
+    function get(ele) {
+      var twipsy = $.data(ele, name)
+
+      if (!twipsy) {
+        twipsy = new Constructor(ele, $.fn.twipsy.elementOptions(ele, options))
+        $.data(ele, name, twipsy)
+      }
+
+      return twipsy
+    }
+
+    function enter() {
+      var twipsy = get(this)
+      twipsy.hoverState = 'in'
+
+      if (options.delayIn == 0) {
+        twipsy.show()
+      } else {
+        twipsy.fixTitle()
+        setTimeout(function() {
+          if (twipsy.hoverState == 'in') {
+            twipsy.show()
+          }
+        }, options.delayIn)
+      }
+    }
+
+    function leave() {
+      var twipsy = get(this)
+      twipsy.hoverState = 'out'
+      if (options.delayOut == 0) {
+        twipsy.hide()
+      } else {
+        setTimeout(function() {
+          if (twipsy.hoverState == 'out') {
+            twipsy.hide()
+          }
+        }, options.delayOut)
+      }
+    }
+
+    if (!options.live) {
+      this.each(function() {
+        get(this)
+      })
+    }
+
+    if (options.trigger != 'manual') {
+      binder   = options.live ? 'live' : 'bind'
+      eventIn  = options.trigger == 'hover' ? 'mouseenter' : 'focus'
+      eventOut = options.trigger == 'hover' ? 'mouseleave' : 'blur'
+      this[binder](eventIn, enter)[binder](eventOut, leave)
+    }
+
+    return this
+  }
+
+  $.fn.twipsy.Twipsy = Twipsy
+
+  $.fn.twipsy.defaults = {
+    animate: true
+  , delayIn: 0
+  , delayOut: 0
+  , fallback: ''
+  , placement: 'above'
+  , html: false
+  , live: false
+  , offset: 0
+  , title: 'title'
+  , trigger: 'hover'
+  }
+
+  $.fn.twipsy.elementOptions = function(ele, options) {
+    return $.metadata ? $.extend({}, options, $(ele).metadata()) : options
+  }
+
+}( window.jQuery || window.ender );
         <link rel="stylesheet" href="bootstrap.min.css" type="text/css"/> 
         <script type="text/javascript" src="jquery.min.js"></script>
         <script type="text/javascript" src="jquery.tmpl.min.js"></script>
+        <script type="text/javascript" src="bootstrap-twipsy.js"></script>
+        <script type="text/javascript" src="bootstrap-modal.js"></script>
         <script type="text/javascript" src="resume.js"></script>
     </head> 
     <style type="text/css">
 <script id="t_me" type="text/x-jquery-tmpl">
     <div class="alert-message block-message message">
         <a class="close" href="#" onclick="$(this).parent().hide()">×</a>
+        <!--<canvas id="mepic" > </canvas>-->
         <p><strong>${time}</strong></p>{{html text}}
         <!--<div class="alert-actions">
         <a class="btn small" href="#">Take this action</a> <a class="btn small" href="#">Or do this</a>
         -->
     </div>
 </script>
+<div id="modal-from-dom" class="modal hide fade in" style="display:none; ">
+            <div class="modal-header">
+              <a href="#" class="close">×</a>
+              <h3>您好:</h3>
+            </div>
+            <div class="modal-body">
+              <p>你是否会歧视非计算机专业的程序员?</p>
+            </div>
+            <div class="modal-footer">
+              <a href="javascript:void(0)" class="btn primary" onclick="alert('我不适合你,请去其他地方看看');location.href='http://www.baidu.com'">是</a>
+              <a href="javascript:void(0)" class="btn secondary" onclick="$('#modal-from-dom').modal('hide')" >否</a>
+            </div>
+</div>
+<button data-controls-modal="modal-from-dom" data-backdrop="true" data-keyboard="true" class="btn danger" style="display:none" id="hello">Launch Modal</button>
     </body>
 </html> 
         <link rel="stylesheet" href="bootstrap.min.css" type="text/css"/> 
         <script type="text/javascript" src="jquery.min.js"></script>
         <script type="text/javascript" src="jquery.tmpl.min.js"></script>
+        <script type="text/javascript" src="bootstrap-twipsy.js"></script>
+        <script type="text/javascript" src="bootstrap-modal.js"></script>
         <script type="text/javascript" src="resume.js"></script>
     </head> 
     <style type="text/css">
     </div>
 </script>
 <script id="t_me" type="text/x-jquery-tmpl">
-    <div class="alert-message block-message error">
+    <div class="alert-message block-message message">
         <a class="close" href="#" onclick="$(this).parent().hide()">×</a>
+        <!--<canvas id="mepic" > </canvas>-->
         <p><strong>${time}</strong></p>{{html text}}
         <!--<div class="alert-actions">
         <a class="btn small" href="#">Take this action</a> <a class="btn small" href="#">Or do this</a>
         -->
     </div>
 </script>
+<div id="modal-from-dom" class="modal hide fade in" style="display:none; ">
+            <div class="modal-header">
+              <a href="#" class="close">×</a>
+              <h3>您好:</h3>
+            </div>
+            <div class="modal-body">
+              <p>你是否会歧视非计算机专业的程序员?</p>
+            </div>
+            <div class="modal-footer">
+              <a href="javascript:void(0)" class="btn primary" onclick="alert('我不适合你,请去其他地方看看');location.href='http://www.baidu.com'">是</a>
+              <a href="javascript:void(0)" class="btn secondary" onclick="$('#modal-from-dom').modal('hide')" >否</a>
+            </div>
+</div>
+<button data-controls-modal="modal-from-dom" data-backdrop="true" data-keyboard="true" class="btn danger" style="display:none" id="hello">Launch Modal</button>
     </body>
 </html> 
     {'time':'2006-2010','school':'湖南大学','text':'这四年在湖大有意义地渡过,挂过科,也拿过奖,干过社团,干过班干,结识一帮好兄弟,'}
     ],
     'jobs':[
-    {'time':'2010-2011','company':'比亚迪太阳能研究部','text':'从事太阳能电池切割钢线研究'},
-    {'time':'2011-now','company':'华夏心理','text':'python软件编写和网站系统维护,服务器配置,数据备份,负责网站数据抓取配合网站开发写自动化脚本.'},
+    {'time':'2010.10-now','company':'华夏心理','text':'python软件编写和网站系统维护,服务器配置,数据备份,负责网站数据抓取配合网站开发写自动化脚本.'},
     ],
     'projects':[
     {'name':'Github','url':'https://github.com/yishenggudou','text':'Github上的项目'},
         $('#jobs').html($('#t_jobs').tmpl(zh.jobs));
         $('#me').html($('#t_me').tmpl(zh.me));
         work();
+        $('#hello').click()
         })
 function work(){
     var li = ['edus','jobs','projects','me','skills'];
             }
             })
     }
+function html5me(){
+    var canvas = document.getElementById('mepic');
+    canvas.style.width='480px';
+    canvas.style.height='360px';
+    var ctx = canvas.getContext('2d');
+    this.wenyi = function(){
+        ctx.font = "20pt Arial";
+        ctx.fillText("文艺青年的我", 10, 50);
+        img_wenyi = new Image();
+        img_wenyi.src = 'http://commondatastorage.googleapis.com/haibo/temp/resume.jpg';
+        ctx.drawImage(img_wenyi,10,80,360,240,200,200,10,10);
+        }
+    this.zhengchang = function(){
+        ctx.font = "20pt Arial";
+        ctx.fillText("正常的我", 10, 50);
+    }
+    this.erbi = function(){
+        ctx.font = "20pt Arial";
+        ctx.fillText("二逼青年的我", 10, 50);
+    }
+    }
     {'time':'2006-2010','school':'湖南大学','text':'这四年在湖大有意义地渡过,挂过科,也拿过奖,干过社团,干过班干,结识一帮好兄弟,'}
     ],
     'jobs':[
-    {'time':'2010-2011','company':'比亚迪太阳能研究部','text':'从事太阳能电池切割钢线研究'},
-    {'time':'2011-now','company':'华夏心理','text':'python软件编写和网站系统维护,服务器配置,数据备份,负责网站数据抓取配合网站开发写自动化脚本.'},
+    {'time':'2010.10-now','company':'华夏心理','text':'python软件编写和网站系统维护,服务器配置,数据备份,负责网站数据抓取配合网站开发写自动化脚本.'},
     ],
     'projects':[
     {'name':'Github','url':'https://github.com/yishenggudou','text':'Github上的项目'},
         $('#jobs').html($('#t_jobs').tmpl(zh.jobs));
         $('#me').html($('#t_me').tmpl(zh.me));
         work();
+        $('#hello').click()
         })
 function work(){
     var li = ['edus','jobs','projects','me','skills'];
             }
             })
     }
+function html5me(){
+    var canvas = document.getElementById('mepic');
+    canvas.style.width='480px';
+    canvas.style.height='360px';
+    var ctx = canvas.getContext('2d');
+    this.wenyi = function(){
+        ctx.font = "20pt Arial";
+        ctx.fillText("文艺青年的我", 10, 50);
+        img_wenyi = new Image();
+        img_wenyi.src = 'http://commondatastorage.googleapis.com/haibo/temp/resume.jpg';
+        ctx.drawImage(img_wenyi,10,80,360,240,200,200,10,10);
+        }
+    this.zhengchang = function(){
+        ctx.font = "20pt Arial";
+        ctx.fillText("正常的我", 10, 50);
+    }
+    this.erbi = function(){
+        ctx.font = "20pt Arial";
+        ctx.fillText("二逼青年的我", 10, 50);
+    }
+    }